package com.wus.common.core.exception;

/**
 * @Description: 接口统一异常类
 * @Author: wus
 * @Date: 2024/12/12 17:33
 */
public class BusinessException extends RuntimeException {

    private static final long serialVersionUID = 7737887002287358220L;
    public static final String CODE_FAIL = "fail";

    private String code;
    private String message;

    public BusinessException(String message) {
        this.message = message;
        this.code = BusinessException.CODE_FAIL;
    }

    public BusinessException(String code, String message) {
        super(message);
        this.message = null;
        this.code = code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String toString() {
        return "BusinessException [code=" + this.code + ", message=" + this.message + "]";
    }

    public static BusinessException newInstance(String message) {
        return new BusinessException(message);
    }
}
